﻿@model LiteBlog.Models.PostModel
@using LiteBlog
@{
    Layout = "~/Views/Shared/_SiteLayout.cshtml";
    var meta = Model.Post.GetMeta();
}

@section MetaSection
{
    <meta property="og:type" content="article" />
    <meta property="og:title" content="@meta.Title" />
    <meta property="og:description" content="@meta.Description" />
    <meta property="og:url" content="@meta.Url" />
    <meta property="og:site_name" content="@meta.Site" />
    @foreach (var tag in meta.Tags)
    {
        <meta property="article:tag" content="@tag" />
    }
    @foreach (var category in meta.Categories)
    {
        <meta property="article:section" content="@category" />
    }
    @foreach (var image in meta.Images)
    {
        <meta property="og:Image" content="@image" />
    }
    <meta property="article:published_time" content="@meta.PublishedTime" />
    <meta property="article:modified_time" content="@meta.UpdatedTime" />
}

@section ScriptSection
{
    <script type="text/javascript">
        $(function () {
            var postsVm = new PostsVm();
            @if (Model.Author != null)
            {
            <text>var author = $.parseJSON('@Html.Json(Model.Author)');
            if (author) {
                postsVm.setAuthor(author.Name, author.Url);
            }
            </text>
            }

            var postVm = new PostVm(postsVm);
            postVm.loadJson(@Html.Json(Model.Post));
            postsVm.posts.push(postVm);

            var pageElem = document.getElementById("page");
            ko.cleanNode(pageElem);
            ko.applyBindings(postsVm, pageElem);
        });
    </script>
}

<div id="posts" class="hidden" data-bind="css: { hidden: false }, foreach: posts">
    @Html.Partial("PostControl")
</div>


